/**
 * Exception
 */


module.exports = (function(){
	var Exception = function(code, message, callback){
		this.init(code, message, callback);
	};
	Exception.prototype.type = 'Exception';	
	Exception.prototype.init = function(code, message, callback){
		this.time = Date();
		this.attributes = {};
	 	this.attributes.code = code;
	 	this.attributes.message = (typeof message == 'undefined') ? 'Error '+this.type: message;
	 	this.attributes.type = this.type;
	 	this.callback = (typeof callback == 'undefined') ? function(){ console.log(this.attributes); }: callback;
	};
	Exception.prototype.printConsole = function(){
		console.log('------------------------------\n'
		+'Error type: '+this.getType()+'\n'
		+'Time: '+this.time+'\n'
		+'code: '+this.getCode()+'\n'
		+'message: '+this.getMessage());
	};
	Exception.prototype.toString = function(){
		return JSON.stringify(this.attributes);
	};
	Exception.prototype.toObject = function(){
		return this.attributes;
	};
	Exception.prototype.getCode = function(){
		return this.attributes.code;
	};
	Exception.prototype.getMessage = function(){
		return this.attributes.message;
	};
	Exception.prototype.getType = function(){
		return this.attributes.type;
	}
	
	return Exception;
}());